<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: treepodia.php 125 2013-09-21 12:11:35Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 125 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 12:11:35 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');

if(isset($_POST) && $_POST['action'] == 'save') {
	$configuration = $db->db_query("SELECT configuration_key,configuration_id, configuration_value, use_function,set_function from ".TABLE_CONFIGURATION." WHERE configuration_group_id = '34' ORDER BY sort_order");

	while(!$configuration->EOF) {
		$db->db_query("UPDATE ".TABLE_CONFIGURATION." SET configuration_value='".$_POST[$configuration->fields['configuration_key']]."' WHERE configuration_key='".$configuration->fields['configuration_key']."'");
		$configuration->MoveNext();
	}

	redirect(href_link('treepodia.php'));
	$configuration->MoveNext();
}
require(DIR_WS_INCLUDES.'metatag.php'); ?>
</style>
</head>
<body>
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<div id="wrapper">
	<table class="outerTable" cellspacing="0" cellpadding="0">
		<tr>
			<td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
				<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
			</td>
			<td class="boxCenter" height="100%" valign="top">
	        	<table class="table_pageHeading" border="0" width="100%" cellspacing="0" cellpadding="0">
		   			<tr>
		     			<td class="pageHeading">Treepodia Administration</td>
					</tr>
				</table>
				<table width="100%">
					<tr width="1">
						<td valign="top"><img src="images/treepodia.gif" alt="" /></td>
						<td>
							<?php echo DESC_1; ?><br /><br />
							<a class="button" href="http://www.treepodia.de/seo-mercari.html" target="_blank">
								zur Anmeldung und Paketauswahl
							</a>
						</td>
					</tr>
				</table>
				<?php echo draw_form('treepodia', 'treepodia.php'); ?>
				<table width="100%"  border="0" cellspacing="0" cellpadding="4">
					<tr>
						<td align="right" colspan="2">
							<input type="submit" class="button" onClick="this.blur();" value="<?php echo BUTTON_SAVE ?>" />
						</td>
					</tr>
					<?php
					$configuration = $db->db_query("SELECT
															configuration_key,
															configuration_id,
															configuration_value,
															use_function,
															set_function
														FROM
															".TABLE_CONFIGURATION."
														WHERE
															configuration_group_id = '34'
														ORDER BY
															sort_order");
					$i=1;
					while(!$configuration->EOF) {
						if (not_null($configuration->fields['use_function'])) {
							$use_function = $configuration->fields['use_function'];
							if (preg_match('/->/', $use_function)) {
								$class_method = explode('->', $use_function);
								if (!is_object(${$class_method[0]})) {
									include(DIR_WS_CLASSES.$class_method[0].'.php');
									${$class_method[0]} = new $class_method[0]();
								}
								$cfgValue = call_function($class_method[1], $configuration->fields['configuration_value'], ${$class_method[0]});

							} else
								$cfgValue = call_function($use_function, $configuration->fields['configuration_value']);

						} else
							$cfgValue = $configuration->fields['configuration_value'];

						if ($configuration->fields['set_function'])
							eval('$value_field = '.$configuration->fields['set_function'].'"'.htmlspecialchars($configuration->fields['configuration_value']).'");');
						else
							$value_field = draw_input_field($configuration->fields['configuration_key'], $configuration->fields['configuration_value'],'class="input_config"');

						if(strstr($value_field,'configuration_value'))
							$value_field=str_replace('configuration_value',$configuration->fields['configuration_key'],$value_field);

						if ($i % 2 == 0)
							$f = '';
						else
							$f = 'dataTableRow';
						echo '	<tr class="'.$f.'" >
									<td width="30%" valign="top" style="border-top: 1px solid #ccc">
										<b>'.constant(strtoupper($configuration->fields['configuration_key'].'_TITLE')).'</b>
									</td>
									<td valign="top" align="left" style="border-top: 1px solid #ccc">
										<p>'.constant(strtoupper( $configuration->fields['configuration_key'].'_DESC')).'</p>
										'.$value_field.'
									</td>
								</tr>';
						$i++;
						$configuration->MoveNext();
					}
					?>
					<tr>
						<td align="right" colspan="2">
							<input type="submit" class="button" onClick="this.blur();" value="<?php echo BUTTON_SAVE ?>" />
							<input type="hidden" class="button" value="save" name="action" />
						</td>
					</tr>
				</table>
				</form>
		    </td>
		</tr>
	</table>
</div>
<?php require(DIR_WS_INCLUDES.'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES.'application_bottom.php'); ?>